package cn.com.callback;
import groovy.json.*;
import groovy.swing.impl.DefaultAction;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.RequestDispatcher;
import cn.com.elite.EliteBean;
import java.security.MessageDigest;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.wisdge.dataservice.Result;
import java.util.Map;
import java.util.Date;
import java.util.HashMap;
import org.json.JSONObject;
import org.json.JSONArray;
import org.json.JSONException;
import cn.com.elite.Util;

/**
 *
 * @Title: apiCreateWO
 * @Description:深圳水务系统工单数据同步接口--外部接口
 * @author: chieh
 * @date 2019-12-17 02:28:00
 *
 */

public class apiCreateWO implements ServiceBackInvoke{
	private static final Log log = LogFactory.getLog(apiCreateWO.class);
	public String doCallBack(EliteBean eliteBean,HttpServletRequest request,HttpServletResponse response) {

		response.setCharacterEncoding("UTF-8");

		String getMethod = request.getMethod();
		log.debug("getMethod:" + getMethod);

		String inData = "";
		String outData = "";
		String dataSourceID = "dataSource";

		BufferedReader iny = null;
		if (getMethod.equals("GET")) {
			inData = request.getParameter("data");
			log.debug("原始Get请求参数:" + inData);
		} else {
			InputStreamReader reader = new InputStreamReader(request.getInputStream(), "UTF-8");
			iny = new BufferedReader(reader);
			String line;
			while ((line = iny.readLine()) != null) {
				inData += line;
			}
			log.debug("原始Post请求参数:" + inData);
		}

		try {
			// 调用处理信息
			JSONObject inObject = new JSONObject(inData);
			log.debug("处理前的Json：" + inObject.toString());

			String sys_source = GetJV(inObject, "sys_source");
			String sys_flag = GetJV(inObject, "sys_flag");
			String arr_data = GetJV(inObject, "data");

			log.debug("解析信息-sys_source：" + sys_source + " sys_flag：" + sys_flag + " arr_data：" + arr_data);
			//必填项校验
			if(sys_flag=='add'&&sys_source=='JT') {
				//新增工单
				outData = SWGDAdd(eliteBean, sys_source, sys_flag, arr_data, dataSourceID);
			}
			else if(sys_flag=='update'&&sys_source=='JT') {
				//更新工单
				outData = SWGDAdd(eliteBean, sys_source, sys_flag, arr_data, dataSourceID);
			}
			else {
				outData =  "{\"resultcode\":\"0\",\"resultmessage\":\"处理失败(接口字段必填校验)\",\"data\":[]}";
			}

		} catch (Exception e) {
			log.error("接口处理异常" + e.getMessage());
			// 失败返回
			outData = "{\"resultcode\":\"0\",\"resultmessage\":\"处理失败(" + e.getMessage() + ")\",\"data\":[]}";

		}

		log.debug("名单接入处理完成返回结果:" + outData);

		return outData;
	}

	// 水务工单录单处理
	public static String SWGDAdd(EliteBean eliteBean, String sys_source, String sys_flag, String inJson, String dataSourceID) {
		long startTime = System.currentTimeMillis();
		JSONArray arrJsonArray;
		Map<String, String> dealMap = new HashMap<String, String>();
		Map<String, String> dealMsgMap = new HashMap<String, String>();
		JSONArray resArray = new JSONArray();
		String reJson = null;
		arrJsonArray = new JSONArray(inJson);
		try {
			arrJsonArray = new JSONArray(inJson);

			int arrInt = arrJsonArray.length();
			log.debug("接入List数量:" + arrInt);
			for (int i = 0; i < arrInt; i++) {

				JSONObject arrCustJson = arrJsonArray.getJSONObject(i);

				//工单状态信息
				String workorderstatus = GetJV(arrCustJson, "workorderstatus");
				String createby = GetJV(arrCustJson, "createby");
				String createname = GetJV(arrCustJson, "createname");
				String createdate = GetJV(arrCustJson, "createdate");
				String modifyby = GetJV(arrCustJson, "modifyby");
				String modifyname = GetJV(arrCustJson, "modifyname");
				String modifydate = GetJV(arrCustJson, "modifydate");

				//登单信息
				String id = GetJV(arrCustJson, "id");
				String usercode = GetJV(arrCustJson, "usercode");
				String linkname = GetJV(arrCustJson, "linkname");
				String userphone = GetJV(arrCustJson, "userphone");
				String username = GetJV(arrCustJson, "username");
				String usermobile = GetJV(arrCustJson, "usermobile");
				String keyword = GetJV(arrCustJson, "keyword");
				String operationsource = GetJV(arrCustJson, "operationsource");
				String sensitive = GetJV(arrCustJson, "sensitive");
				String rangecodearea = GetJV(arrCustJson, "rangecodearea");
				String rangecodewater = GetJV(arrCustJson, "rangecodewater");
				String rangecodedepart = GetJV(arrCustJson, "rangecodedepart");
				String organization = GetJV(arrCustJson, "organization");
				String wateraddress = GetJV(arrCustJson, "wateraddress");
				String street = GetJV(arrCustJson, "street");
				String registerbusiness1 = GetJV(arrCustJson, "registerbusiness1");
				String registerbusiness2 = GetJV(arrCustJson, "registerbusiness2");
				String registerbusiness3 = GetJV(arrCustJson, "registerbusiness3");
				String problemdescription = GetJV(arrCustJson, "problemdescription");
				String opinion = GetJV(arrCustJson, "opinion");
				String isnoresolve = GetJV(arrCustJson, "isnoresolve");
				String emergencyrepair = GetJV(arrCustJson, "emergencyrepair");
				String isovertime = GetJV(arrCustJson, "isovertime");
				String isdoortodoor = GetJV(arrCustJson, "isdoortodoor");
				String datelimit = GetJV(arrCustJson, "datelimit");
				String rangecodemobile = GetJV(arrCustJson, "rangecodemobile");
				String isvalidity = GetJV(arrCustJson, "isvalidity");
				String isautoreturnvisit = GetJV(arrCustJson, "isautoreturnvisit");
				String staffid = GetJV(arrCustJson, "staffid");
				String staffname = GetJV(arrCustJson, "staffname");
				String registrant = GetJV(arrCustJson, "registrant");
				String registrantname = GetJV(arrCustJson, "registrantname");
				String registerdate = GetJV(arrCustJson, "registerdate");
				String ordertime = GetJV(arrCustJson, "ordertime");
				String workorderreceiver = GetJV(arrCustJson, "workorderreceiver");
				String receivername = GetJV(arrCustJson, "receivername");
				//受理人短信号码内容
				String smsreceiver = GetJV(arrCustJson, "smsreceiver");
				String smsreceivername = GetJV(arrCustJson, "smsreceivername");
				String smstel = GetJV(arrCustJson, "smstel");
				String smscontent = GetJV(arrCustJson, "smscontent");
				//处理信息
				String handlebusiness1 = GetJV(arrCustJson, "handlebusiness1");
				String handlebusiness2 = GetJV(arrCustJson, "handlebusiness2");
				String handlebusiness3 = GetJV(arrCustJson, "handlebusiness3");
				String leakagecondition = GetJV(arrCustJson, "leakagecondition");
				String handledescription = GetJV(arrCustJson, "handledescription");
				String remarks = GetJV(arrCustJson, "remarks");
				String failurecause = GetJV(arrCustJson, "failurecause");
				String starttime = GetJV(arrCustJson, "starttime");
				String finishtime = GetJV(arrCustJson, "finishtime");
				String workingday = GetJV(arrCustJson, "workingday");
				String handlerby = GetJV(arrCustJson, "handlerby");
				String handlername = GetJV(arrCustJson, "handlername");
				String handlerphone = GetJV(arrCustJson, "handlerphone");
				String responsibleperson = GetJV(arrCustJson, "responsibleperson");
				String responsiblename = GetJV(arrCustJson, "responsiblename");
				String arriveddate = GetJV(arrCustJson, "arriveddate");
				String firstarrivaldate = GetJV(arrCustJson, "firstarrivaldate");
				String checkgrade = GetJV(arrCustJson, "checkgrade");
				String registercode = GetJV(arrCustJson, "registercode");
				String registercodename = GetJV(arrCustJson, "registercodename");
				String requestdate = GetJV(arrCustJson, "requestdate");
				String doordate = GetJV(arrCustJson, "doordate");
				String estatename = GetJV(arrCustJson, "estatename");
				String userpointtypeid = GetJV(arrCustJson, "UserPointTypeid");


				//回访信息
				String userreflect = GetJV(arrCustJson, "userreflect");
				String serviceattitude = GetJV(arrCustJson, "serviceattitude");
				String quality = GetJV(arrCustJson, "quality");
				String returnpeople = GetJV(arrCustJson, "returnpeople");
				String returnname = GetJV(arrCustJson, "returnname");
				String feedbacktime = GetJV(arrCustJson, "feedbacktime");
				String satisfaction = GetJV(arrCustJson, "satisfaction");
				String empattire = GetJV(arrCustJson, "empattire");
				String feedback = GetJV(arrCustJson, "feedback");


				//查询现有当前工单编号是否存在现有工单
				def getSelectSQL = eliteBean.chaxun_sql("select Relation_ID from TABCswgdmerge where case when uciswordid is not null or uciswordid!='' then uciswordid else workorderid end = '" + id + "'", dataSourceID);
				log.debug("查询当前同步的工单是否已经存在 SQL:" + getSelectSQL + " 结果数量:" + getSelectSQL.size());

				String old_Relation_ID = null;
				if(getSelectSQL.size() > 0) {
					old_Relation_ID = getSelectSQL.get(0).get("Relation_ID");
				}else{
					old_Relation_ID = null;
				}

				//处理结果字段dealResult 1成功 其他失败，处理原则：新增是工单编号不能存在，更新是工单编号必须存在
				String dealResult = "";
				String dealMessage = "";
				if(isNull(workorderstatus) || isNull(createby) || isNull(createname) || isNull(createdate) || isNull(modifyby) || isNull(modifyname) || isNull(modifydate) || isNull(id) || isNull(linkname) ||isNull(userphone) || isNull(rangecodearea) || isNull(rangecodewater) || isNull(wateraddress) || isNull(registerbusiness1) || isNull(registerbusiness2) || isNull(registerbusiness3) || isNull(problemdescription) || isNull(workorderreceiver) || isNull(receivername)) {

					dealResult = "0";
					dealMessage = isNullMSG("workorderstatus", workorderstatus) + isNullMSG("createby", createby) + isNullMSG("createname", createname) + isNullMSG("createdate", createdate) + isNullMSG("modifyby", modifyby) + isNullMSG("modifyname", modifyname) + isNullMSG("modifydate", modifydate) + isNullMSG("linkname", linkname) +isNullMSG("id", id) + isNullMSG("userphone", userphone) + isNullMSG("rangecodearea", rangecodearea) + isNullMSG("rangecodewater", rangecodewater) + isNullMSG("wateraddress", wateraddress) + isNullMSG("registerbusiness1", registerbusiness1) + isNullMSG("registerbusiness2", registerbusiness2) + isNullMSG("registerbusiness3", registerbusiness3) + isNullMSG("problemdescription", problemdescription) + isNullMSG("workorderreceiver", workorderreceiver) + isNullMSG("receivername", receivername);

				}else {
					if(sys_flag=='add') {
						//新建工单
						if(old_Relation_ID == null || old_Relation_ID.length() <= 0) {
							try {

								String Relation_ID = UUID.randomUUID().toString();
								log.debug("当前工单编号不存在新建Relation_ID:" + Relation_ID);
								String[] data=new String[5];
								//判断非龙华派单中心的单，正常由UCIS给CRM直接到处理节点； 否则改为到龙华派单中心节点
								def step='';
								def state='';
								if(rangecodewater!='640') {
									 step='ZUOC2L';
									 state='SENDNS';
								}else {
									step='GSN988';
									state='CLOSE';
								}
								data[0] = "Insert Into Tabcswgdmerge (Relation_Id, Workorderid, Usercode, Linkname, Userphone, Username, Usermobile, Keyword, Operationsource, Sensitive, Rangecodearea, Rangecodewater, Wateraddress, Street, Registerbusiness1, Registerbusiness2, Registerbusiness3, Problemdescription, Opinion, Isnoresolve, Emergencyrepair, Isovertime, Isdoortodoor, Datelimit, Rangecodemobile, Isvalidity, Isautoreturnvisit, Staffid, Registrant, Registerdate, Ordertime, Smsreceiver, Smstel, Smscontent, Handlebusiness1, Handlebusiness2, Handlebusiness3, Leakagecondition, Handledescription, Remarks, Failurecause, Starttime, Finishtime, Workingday, Handlerby, Handlerphone, Responsibleperson, Arriveddate, Firstarrivaldate, Checkgrade, Registercode, Requestdate, Userreflect, Serviceattitude, Quality, Returnpeople, Feedbacktime, Satisfaction, Empattire, Feedback, Workorderstatus, Createby, Createdate, Modifyby, Modifydate, Rangecodedepart, Doordate, Workorderreceiver, Staffname, Registrantname, Receivername, Smsreceivername, Handlername, Responsiblename, Registercodename, Returnname, Createname, Modifyname, Organization,RECEIVER,estatename,userpointtypeid) Values ('" + Relation_ID + "', '" + id + "', '" + usercode + "', '" + linkname + "', '" + userphone + "', '" + username + "', '" + usermobile + "', '" + keyword + "', '" + operationsource + "', '" + sensitive + "', '" + rangecodearea + "', '" + rangecodewater + "', '" + wateraddress + "', '" + street + "', '" + registerbusiness1 + "', '" + registerbusiness2 + "', '" + registerbusiness3 + "', '" + problemdescription + "', '" + opinion + "', '" + isnoresolve + "', '" + emergencyrepair + "', '" + isovertime + "', '" + isdoortodoor + "', '" + datelimit + "', '" + rangecodemobile + "', '" + isvalidity + "', '" + isautoreturnvisit + "', '" + staffid + "', '" + registrant + "', '" + registerdate + "', '" + ordertime + "', '" + smsreceiver + "', '" + smstel + "', '" + smscontent + "', '" + handlebusiness1 + "', '" + handlebusiness2 + "', '" + handlebusiness3 + "', '" + leakagecondition + "', '" + handledescription + "', '" + remarks + "', '" + failurecause + "', '" + starttime + "', '" + finishtime + "', '" + workingday + "', '" + handlerby + "', '" + handlerphone + "', '" + responsibleperson + "', '" + arriveddate + "', '" + firstarrivaldate + "', '" + checkgrade + "', '" + registercode + "', '" + requestdate + "', '" + userreflect + "', '" + serviceattitude + "', '" + quality + "', '" + returnpeople + "', '" + feedbacktime + "', '" + satisfaction + "', '" + empattire + "', '" + feedback + "', '" + workorderstatus + "', '" + createby + "', '" + createdate + "', '" + modifyby + "', '" + modifydate + "', '" + rangecodedepart + "', '" + doordate + "', '" + workorderreceiver + "', '" + staffname + "', '" + registrantname + "', '" + receivername + "', '" + smsreceivername + "', '" + handlername + "', '" + responsiblename + "', '" + registercodename + "', '" + returnname + "', '" + createname + "', '" + modifyname + "', '" + organization + "', '" + rangecodearea + "', '" + estatename +"', '" + userpointtypeid + "')";
								
								data[1] = "Insert Into Objective (Objective_Guid, Objectivetype_Id, Handleby_Id, Handlegroup_Id, Priority_Id, Expireddate, Customer_Guid, Firstcontactdate, Lastcontactdate, Objectivestatus, Iscontact, Trytimes, Successfulcontacttimes, Createdby, Createddate, Modifiedby, Modifieddate, Expecttradedate, Failreason, Quantity, Amount, Obstarttime, Obendtime, Firstcalldate, Failure_Attempt, Passflag, Localtrycount, Lastassigndate, Isanswer, Prepossibility, Expectstarttime, Workorderframe_Id, Category, Forecastdate, Workorderid, Objectivesubstatus, Map_Id, Curstep_Id_Map, Max_Attempt, Nocontacttry) Values ('" + Relation_ID + "', 'BSC5YH', Null, 'CW0001', 'NORMAL', '" + createdate + "', '1', Null, Null, 'OPEN', '0', '0', '0', '" + createby + "', '" + createdate + "', '" + modifyby + "', '" + modifydate + "', Null, '', '0', '0', Null, Null, Null, '0', '0', '0', Null, '0', '.00', Null, 'ZHS14C', 'WORDER', '" + createdate + "', '" + id + "', 'OPEN ', 'ZHS14C', '" + step+ "', '0', '0')";
								data[2] = "Insert Into Elitetask (Elitetask_Guid, Objective_Guid, Objectivetype_Id, Expectstarttime, Expectendtime, Priority, Handleby_Id, Handlegroup_Id, Createdby, Createddate, Modifiedby, Modifieddate, Comments, Customer_Guid, Customerlevel, Localtrycount, Curstepstatus, Curstep_Id, Stepforecastdate, Curstep_Id_Map, Map_Id, Objectivesubstatus, Elitetaskstatus, Obflag) Values (Newid(), '" + Relation_ID + "', 'BSC5YH', '" + createdate + "', '" + createdate + "', 'NORMAL', Null, 'CW0001', '" + createby + "', '" + createdate + "', '" + modifyby + "', '" + modifydate + "', '', '1', Null, '0', 'OPEN ', '" + step+ "', '" + createdate + "', '" + step+ "', 'ZHS14C', 'SU0000', Null, '0')";
								data[3] = "Insert Into Workorderstep3 (Workorder_Guid, Workorderstep_Guid, Oldhandleby_Id, Oldhandlegroup_Id, Handleby_Id, Handlegroup_Id, Workorderstepstatus, Comments, Modifieddate, Workorderstepid, Stepexpired, Child_Id, Stepstart, Cur_Expiredflag, Cur_Expiredlen, Event_Guid, From_Stepidmap, To_Stepidmap, Workstarttime, Workendtime) Values ('" + Relation_ID + "', Newid(), '" + createby + "', 'CW0001', '', 'CW0001', '" + state+ "', '', '" + createdate + "', Null, '" + createdate + "', Null, '" + createdate + "', '0', '0', '', 'BOVH1J', '" + step+ "', '" + createdate + "', '" + createdate + "')";
								data[4] = "Insert Into Workorderpath3 (Workorder_Guid, Tostepid, Handlegroup, Handleby, Modifieddate, Fromstepid, Workorderpath_Guid, Woframe_Id, Fromframeid, From_Stepidmap, To_Stepidmap, Handlerole_Id) Values ('" + Relation_ID + "', Null, 'CW0001', '" + createby + "', '" + createdate + "', Null, Newid(), 'ZHS14C', '', 'BOVH1J', '" + step+ "', Null)";
								
								log.debug("当前工单编号不存在新建结果SQL:" + data.toString());
								def dataresult = eliteBean.updateBatch(data, dataSourceID);
								log.debug("当前工单编号不存在新建结果SQL结果:" + dataresult.toString());
								dealResult = "1";
							} catch (Exception e) {
								dealResult = "0";
								dealMessage = "当前工单编号不存在新建结果SQL异常";
								log.error(dealMessage + ":" + e.getMessage());
							}
						}else {
							dealResult = "0";
							dealMessage = "当前工单编号已经存在不能新建";
							log.debug(dealMessage + "，Relation_ID:" + old_Relation_ID);

						}

					}else {
						//更新工单
						if(old_Relation_ID == null || old_Relation_ID.length() <= 0) {
							dealResult = "0";
							dealMessage = "当前工单编号CRM系统不存在不能更新";
							log.debug(dealMessage + "，ID:" + id);
						}else {
							try {
								String[] data=new String[3];
								data[0] = "Insert Into Tabcswgdmerge_His Select Newid(),* From Tabcswgdmerge Where Relation_Id = '" + old_Relation_ID + "'";
								data[1] = "Delete from TABCswgdmerge where workorderid = '" + id + "' and Relation_ID = '" + old_Relation_ID + "'";
								data[2] = "Insert Into Tabcswgdmerge (Relation_Id, Workorderid, Usercode, Linkname, Userphone, Username, Usermobile, Keyword, Operationsource, Sensitive, Rangecodearea, Rangecodewater, Wateraddress, Street, Registerbusiness1, Registerbusiness2, Registerbusiness3, Problemdescription, Opinion, Isnoresolve, Emergencyrepair, Isovertime, Isdoortodoor, Datelimit, Rangecodemobile, Isvalidity, Isautoreturnvisit, Staffid, Registrant, Registerdate, Ordertime, Smsreceiver, Smstel, Smscontent, Handlebusiness1, Handlebusiness2, Handlebusiness3, Leakagecondition, Handledescription, Remarks, Failurecause, Starttime, Finishtime, Workingday, Handlerby, Handlerphone, Responsibleperson, Arriveddate, Firstarrivaldate, Checkgrade, Registercode, Requestdate, Userreflect, Serviceattitude, Quality, Returnpeople, Feedbacktime, Satisfaction, Empattire, Feedback, Workorderstatus, Createby, Createdate, Modifyby, Modifydate, Rangecodedepart, Doordate, Workorderreceiver, Staffname, Registrantname, Receivername, Smsreceivername, Handlername, Responsiblename, Registercodename, Returnname, Createname, Modifyname, Organization,RECEIVER,estatename,userpointtypeid) Values ('" + old_Relation_ID + "', '" + id + "', '" + usercode + "', '" + linkname + "', '" + userphone + "', '" + username + "', '" + usermobile + "', '" + keyword + "', '" + operationsource + "', '" + sensitive + "', '" + rangecodearea + "', '" + rangecodewater + "', '" + wateraddress + "', '" + street + "', '" + registerbusiness1 + "', '" + registerbusiness2 + "', '" + registerbusiness3 + "', '" + problemdescription + "', '" + opinion + "', '" + isnoresolve + "', '" + emergencyrepair + "', '" + isovertime + "', '" + isdoortodoor + "', '" + datelimit + "', '" + rangecodemobile + "', '" + isvalidity + "', '" + isautoreturnvisit + "', '" + staffid + "', '" + registrant + "', '" + registerdate + "', '" + ordertime + "', '" + smsreceiver + "', '" + smstel + "', '" + smscontent + "', '" + handlebusiness1 + "', '" + handlebusiness2 + "', '" + handlebusiness3 + "', '" + leakagecondition + "', '" + handledescription + "', '" + remarks + "', '" + failurecause + "', '" + starttime + "', '" + finishtime + "', '" + workingday + "', '" + handlerby + "', '" + handlerphone + "', '" + responsibleperson + "', '" + arriveddate + "', '" + firstarrivaldate + "', '" + checkgrade + "', '" + registercode + "', '" + requestdate + "', '" + userreflect + "', '" + serviceattitude + "', '" + quality + "', '" + returnpeople + "', '" + feedbacktime + "', '" + satisfaction + "', '" + empattire + "', '" + feedback + "', '" + workorderstatus + "', '" + createby + "', '" + createdate + "', '" + modifyby + "', '" + modifydate + "', '" + rangecodedepart + "', '" + doordate + "', '" + workorderreceiver + "', '" + staffname + "', '" + registrantname + "', '" + receivername + "', '" + smsreceivername + "', '" + handlername + "', '" + responsiblename + "', '" + registercodename + "', '" + returnname + "', '" + createname + "', '" + modifyname + "', '" + organization  + "', '" + rangecodearea+"','" + estatename + "', '" + userpointtypeid + "')";

								log.debug("当前工单编号已经存在执行更新结果SQL:" + data.toString());
								def dataresult = eliteBean.updateBatch(data, dataSourceID);
								log.debug("当前工单编号已经存在执行更新结果SQL结果:" + dataresult.toString());

								dealResult = "1";
								log.debug("当前工单编号已经存在执行更新结果，dataresult:" + dataresult);
							} catch (Exception e) {
								dealResult = "0";
								dealMessage = "当前工单编号已经存在执行更新结果SQL异常";
								log.error(dealMessage + ":" + e.getMessage());
							}
						}

					}
				}

				log.debug("当前工单编号ID:" + id + " 处理结果Code:" + dealResult + " 处理结果Message:" + dealMessage);
				dealMap.put(id, dealResult);
				dealMsgMap.put(id, dealMessage);
			}

			// 将每条处理结果转换为JSONArray
			int j = 0;
			for (Map.Entry<String, String> m : dealMap.entrySet()) {
				JSONObject resObject = new JSONObject();
				resObject.put("id", m.getKey());
				resObject.put("code", m.getValue());
				resObject.put("message", dealMsgMap.get(m.getKey()).toString());
				resArray.put(j, resObject);
				j++;
			}

			//生成处理完成时间
			long endTime = System.currentTimeMillis();

			// 包装拼接返回JSONObject
			reJson = "{\"resultcode\":\"1\",\"resultmessage\":\"处理完成、调用问题处理时长(毫秒):" + (endTime - startTime) + "\",\"data\":" + resArray.toString() + "}";

		} catch (JSONException e) {
			long endTime = System.currentTimeMillis();
			reJson = "{\"resultcode\":\"0\",\"resultmessage\":\"处理失败(" + e.getMessage() + "),调用问题处理时长(毫秒):" + (endTime - startTime) + "\",\"data\":[]}";
		}

		return reJson;
	}

	// 解析Json值
	public static String GetJV(JSONObject inJson, String getKey) {
		String Rev_Value = null;
		try {
			Rev_Value = inJson.getString(getKey);
		} catch (Exception e) {
			try {
				Rev_Value = String.valueOf(inJson.getInt(getKey));
			} catch (Exception e1) {
				try {
					Rev_Value = String.valueOf(inJson.getJSONArray(getKey));
				} catch (Exception e2) {
					try {
						Rev_Value = String.valueOf(inJson.getJSONObject(getKey));
					} catch (Exception e3) {
						Rev_Value = "";
					}
				}
			}
		} finally {
			if (Rev_Value == null || Rev_Value.equals("null") || Rev_Value.length() <= 0) {
				Rev_Value = "";
			} else {
			}
		}
		return Rev_Value;
	}

	// 非空校验isNull
	public static boolean isNull(String value) {

		boolean reFlag = true;
		if (value == "" || value.length() <= 0) {
			reFlag = true;
		} else {
			reFlag = false;
		}
		log.debug(reFlag);
		return reFlag;
	}

	// 非空校验isNullMSG
	public static String isNullMSG(String key, String value) {

		String reResult = "";
		if (value == "" || value.length() <= 0) {
			reResult = key + "必填字段;";
		}
		return reResult;
	}

}
